package com.auxgroup.smarthome;

import com.auxgroup.smarthome.jwt.JwtConstant;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.GetMapping;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.PostConstruct;

/**
 * Created by kevinchen on 2017/7/24.
 */
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@EnableAsync
public class UpmsApplication {
    public static void main(String[] args) {
        // 设置headless模式, 使用java.awt相关画图功能
        SpringApplication app = new SpringApplication(UpmsApplication.class);
         app.addListeners(new ApplicationEventListener());
         app.run(args);
//        SpringApplication.run(UpmsApplication.class, args);
    }

    @ApiIgnore
    @GetMapping(value = "/index")
    public String index(){
        return "welcome to use GenericFramework of gizwits";
    }

//    @Override
//    public void addFormatters(FormatterRegistry registry) {
//        registry.addConverterFactory(new StringToEnumConverterFactory());
//    }

//    @Bean
//    public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
//        final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
//        ObjectMapper mapper = converter.getObjectMapper();
//        // 为mapper注册一个带有SerializerModifier的Factory，此modifier主要做的事情为：当序列化类型为array，list、set时，当值为空时，序列化成[]
//        mapper.setSerializerFactory(mapper.getSerializerFactory().withSerializerModifier(new NullHandleSerializerModifier()));
//        converter.setSupportedMediaTypes(ImmutableList.of(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON));
//        return converter;
//    }

    @PostConstruct
    public void init() {
        // 初始化JWT配置
        JwtConstant.readProperties();
    }

}
